<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="btn1">点击</button>
  <ul>
    <li>1</li>
    <li class="active">2</li>
    <li class="active">3</li>
  </ul>
  <input type="text" name="username" id="">

  <script>
    var arr1 = [1, 2, 3];
    //1.通过getElementById
    var oBtn1 = document.getElementById("btn1");
    //2.通过getElementsByTagName
    var lis = document.getElementsByTagName('li');//永远拿到的是一个“数组”
    //lis.push(777)伪数组没有push属性
    console.log(lis);
    for (var i = 0; i < lis.length; i++) {
      console.log(lis[i]);
    }
    console.log(arr1);
    arr1.push(666);

    //3.通过getElementsByClassName
    var lis2 = document.getElementsByClassName('active');
    console.log(lis2);//若为空，则显示属性值为0

    //4.通过getElementsByName
    var lis3 = document.getElementsByName('username');
    console.log(lis3);

    //5.通过querySelector
    var oBtn6 = document.querySelector('#btn1');
    console.log(oBtn6);

    //6.通过
    var lis6 = document.querySelectorAll('.active')
    console.log(lis6)
  </script>


</body>

</html>